﻿//Register.aspx.cs
////////////////////////////////////////
////////////////////////////////////////
//当用户点击注册时显示，显示注册页面
////////////////////////////////////////
////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;

public partial class Signin : System.Web.UI.Page
{
    CommonClass ccObj = new CommonClass();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default.aspx");
    }
    protected void btnReset_Click(object sender, EventArgs e)
    {
        this.txtName.Text = "";
        this.txtPassword.Text = "";
        this.txtconfirmPassword.Text = "";
        this.txtTrueName.Text = "";
        this.txtPhone.Text = "";
        this.txtEmail.Text = "";
        this.txtAddress.Text = "";
        this.lbtnCheckName.Visible = true;
        this.CheckShow.Visible = false;
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Client user = new Client();
        if (0 < user.Register(txtName.Text.ToString().Trim(),
                txtTrueName.Text.ToString().Trim(),
                txtPassword.Text.ToString().Trim(),
                txtAddress.Text.ToString().Trim(),
                txtPhone.Text.ToString().Trim(),
                txtEmail.Text.ToString().Trim()))
        {
            Response.Write(ccObj.MessageBox("恭喜您注册成功！", "Default.aspx"));
        }
        else
        {
            Response.Write(ccObj.MessageBox("注册失败，该用户名已存在！"));
        }
    }
    protected void lbtnCheckName_Click(object sender, EventArgs e)
    {
        lbtnCheckName.Visible = false;
        /////////////////////////////
        /////////////////////////////
        //利用函数对this.txtName.Text.Trim()在用户表中进行检查，若存在此用户名，则
        Client user = new Client();
        if (0 == user.TestRegister(this.txtName.Text.Trim()))
        {
            this.CheckShow.Visible = true;
            this.CheckShow.ForeColor = System.Drawing.Color.Red;
            this.CheckShow.Text = "×此用户名已存在!";
        }
        else
        {
            this.CheckShow.Visible = true;
            this.CheckShow.ForeColor = System.Drawing.Color.Green;
            this.CheckShow.Text = "√此用户名可用";
        }
    }
}
